// local api 
// import  { CommandConfig as command } from '../../mock/modules/CommandConfig'

export async function postRequest(url, data): Promise<any> {
  console.log("[mock] url:" +url )
  console.log("[mock] data:" ,data )
  const list = [
    { prose: '服务器异常' },
    { prose: '操作失败' }
  ]  
  if (url.indexOf('login') > -1) { 
    return new Promise((resolve, reject) => { 
      console.log(reject)
        const dd = {
          status: Math.random() > 0.5 ? 200 : 500,
          data: {
            "account": "王俊",
            "password": "123456",
            "organizationName": "技术产品中心",
            "token": "5c34bd829f7c4495b23d70b29247e3c1"
          },
          message: list[Math.floor(Math.random() * list.length)]['prose']
        } 
        console.log("[mock] result:" ,dd )
        resolve(dd); 
    });
  }

  return new Promise((resolve, reject) => {
    console.log(reject)
    if(Math.random() > 0.5){
      const dd = {
        status: 500,
          data: data,
          message: list[Math.floor(Math.random() * list.length)]['prose'],
      } 
      console.log("[mock] result:" ,dd )
      resolve(dd);
    }else{   
      const dd = {
        status: 200,
          data: data,
          message: list[Math.floor(Math.random() * list.length)]['prose'],
      } 

      console.log("[mock] result:" ,dd )
      resolve(dd); 
    } 
  });
}